/*
 * Copyright 2012 Marsrutai.lt
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lt.marsrutai.mobile.android.activity;

import lt.marsrutai.mobile.android.activity.intent.RunStopsIntentHolder;
import lt.marsrutai.mobile.android.fragment.RunStopsFragment;
import android.support.v4.app.ListFragment;

public class RunStopsActivity extends BaseActivity {

    @Override
    public boolean onNavigationItemSelected(int itemPosition, long itemId) {
        RunStopsIntentHolder sourceIntentHolder = new RunStopsIntentHolder(getIntent());

//        switch (itemPosition) {
//        case 1:
//            StopTimesIntentHolder intentHolder = new StopTimesIntentHolder(this);            
//            intentHolder.setScopeFolder(sourceIntentHolder.getScopeFolder());
//            intentHolder.setScopeName(sourceIntentHolder.getScopeName());
//            intentHolder.setTransportId(sourceIntentHolder.getTransportId());
//            intentHolder.setScheduleId(sourceIntentHolder.getScheduleId());
//            intentHolder.setScheduleName(sourceIntentHolder.getScheduleName());
//            intentHolder.setScheduleTrackName(sourceIntentHolder.getScheduleTrackName());
//            intentHolder.setTrackId(sourceIntentHolder.getTrackId());
//            intentHolder.setTrackName(sourceIntentHolder.getTrackName());
//            intentHolder.setStopId(sourceIntentHolder.getStopId());
//            intentHolder.setStopName(sourceIntentHolder.getStopName());
//            intentHolder.setStopDirectionName(sourceIntentHolder.getStopDirectionName());
//            startActivity(intentHolder.getIntent());
//            break;
//        case 2:
//            StopsIntentHolder stopsintentHolder = new StopsIntentHolder(this);
//            stopsintentHolder.setScopeFolder(sourceIntentHolder.getScopeFolder());
//            stopsintentHolder.setScopeName(sourceIntentHolder.getScopeName());
//            stopsintentHolder.setTransportId(sourceIntentHolder.getTransportId());
//            stopsintentHolder.setScheduleId(sourceIntentHolder.getScheduleId());
//            stopsintentHolder.setScheduleName(sourceIntentHolder.getScheduleName());
//            stopsintentHolder.setScheduleTrackName(sourceIntentHolder.getScheduleTrackName());
//            stopsintentHolder.setTrackId(sourceIntentHolder.getTrackId());
//            stopsintentHolder.setTrackName(sourceIntentHolder.getTrackName());
//            startActivity(stopsintentHolder.getIntent());
//            break;            
//        case 3:
//            TracksIntentHolder tracksintentHolder = new TracksIntentHolder(this);
//            tracksintentHolder.setScopeFolder(sourceIntentHolder.getScopeFolder());
//            tracksintentHolder.setScopeName(sourceIntentHolder.getScopeName());
//            tracksintentHolder.setScheduleId(sourceIntentHolder.getScheduleId());
//            tracksintentHolder.setScheduleName(sourceIntentHolder.getScheduleName());
//            tracksintentHolder.setScheduleTrackName(sourceIntentHolder.getScheduleTrackName());
//            startActivity(tracksintentHolder.getIntent());
//            break;
//        case 4:
//            SchedulesIntentHolder schedulesIntentHolder = new SchedulesIntentHolder(this);
//            schedulesIntentHolder.setScopeFolder(sourceIntentHolder.getScopeFolder());
//            schedulesIntentHolder.setScopeName(sourceIntentHolder.getScopeName());
//            startActivity(schedulesIntentHolder.getIntent());
//            break;
//        case 5:
//            startActivity(new Intent(this, AvailableMobileScopesActivity.class));
//            break;
//        default:
//            return false;
//        }

        return false;
    }

    @Override
    public NavMenuData getNavMenuData() {
        RunStopsIntentHolder intentHolder = new RunStopsIntentHolder(getIntent());
        return new NavMenuData(new String[] { intentHolder.getStopName() +  " (" + intentHolder.getScheduledTime() + ")" });
    }

    @Override
    public void setupView() {
        if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
            ListFragment fragment = new RunStopsFragment();
            fragment.setArguments(getIntent().getExtras());
            getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
        }
    }

}
